﻿@model Model.AppUserList
@{
    ViewBag.Title = "AreaPort";
    Layout = "~/Views/Shared/_JQBaseLayOut.cshtml";
}
@using Model

@section JQscriptSection{
    <script type="text/javascript">
        $(document).ready(function () {
            $('#AreaID').combobox('setValue', '0');
            $('#PortID').combobox('setValue', '0');
            InitGrid();

        });

        HandleDom.ClassTriggerClick("icon-add", function () {
            $('#hiddenAREAPORTID').val();
            HandleDialog.OpenDialogByAdd('dlg', '添加区域发货口关联', function () {
                HandleData.ClearForm('location');
                $('#AreaID1').combobox('setValue', '0');
                $('#PortID1').combobox('setValue', '0');

            });
        });

        HandleDom.ClassTriggerClick("icon-edit", function () {
            var row = HandleData.GetDataGridSelected("dg");
            edit(row);
        });

        HandleDom.IdTriggerBlur("icon-Reload", function () {
            InitGrid();
        });

        //编辑
        function edit(row) {
            HandleData.ClearForm('location');
            HandleDialog.OpenDialog(row, 'dlg', '编辑区域发货口关联', function () {
                HandleData.SetValueComboBox('AreaID1', row.AREAID);
                HandleData.SetValueComboBox('PortID1', row.SENDPORTID);
                $('#hiddenAREAPORTID').val(row.AREAPORTID);

            });
        }

        function saveData(isClose) {
            HandleRequest.submitForm('location', '@Url.Action("SaveData", "AreaPort")', function (data) {
                eval('data=' + data);
                if (data.success == true) {
                    layer.alert('执行成功!', 9);
                    InitGrid();
                    HandleDialog.CloseDialog('dlg');
                } else {
                    layer.msg(data.msg, 1);
                }

            });
        }

        function InitGrid() {
            var areaID = $('#AreaID').combobox('getValue');
            var portID = $('#PortID').combobox('getValue');
            queryParams = {
                area: areaID,
                sendPort: portID
            }
            HandleData.InitDataGrid('dg', '/AreaPort/InitJsonResult', 'toolbar', queryParams, 'AREAPORTID', true, function (data) { },
                function (rowIndex, rowData) {//双击
                    edit(rowData);
                });
        }
    </script>
}

<body style="background-color: ButtonFace; font-size: 17px">
    <div class="easyui-panel" title="查询条件" style="height: 130px; padding: 5px; background: #fafafa; width: 1700px;">
        <form id="query" method="post">
            <table>
                <tr>
                    <td>所属区域:
                    </td>
                    <td>
                        <input id="AreaID" class="easyui-combobox" name="AreaID" style="width: 155px;" data-options="required:true,valueField:'fieldvalue',textField:'lookup',url:'@Url.Action("AreaList", "AreaPort", new { IsSetAll = "0" })',editable:false">
                    </td>
                    <td>发货口:
                    </td>
                    <td>

                        <input id="PortID" class="easyui-combobox" name="PortID" style="width: 155px;" data-options="required:true,valueField:'fieldvalue',textField:'lookup',url:'@Url.Action("SendPortList", "AreaPort", new { IsSetAll = "0" })',editable:false">
                    </td>
                    <td>
                        <a id="btnSerach" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="InitGrid()">确定</a>
                    </td>
                </tr>
            </table>
        </form>

    </div>
    <div style="min-height: 720px; width: 1700px;">
        <table id="dg" title="数据明细" style="min-height: 600px;">
            <thead>
                <tr>
                    <th data-options="field:'AREAPORTID',width:30">主键ID</th>
                    <th data-options="field:'AREAID',width:50">区域编码</th>
                    <th data-options="field:'AreaName',width:50">区域名称</th>
                    <th data-options="field:'SENDPORTID',width:50">发货口编码</th>
                    <th data-options="field:'SendPortName',width:50">发货口</th>
                    <th data-options="field:'CREATER',width:50">创建人</th>
                    <th data-options="field:'CREATETIME',width:100,sortable:true,formatter:function(value, rowData, rowIndex){ return FormatData.formatDate(value);}">创建时间</th>
                    <th data-options="field:'MODITOR',width:50">修改人</th>
                    <th data-options="field:'MODITIME',width:100,sortable:true,formatter:function(value, rowData, rowIndex){ return FormatData.formatDate(value);}">修改时间</th>
                    <th data-options="field:'REMARK',width:100">备注</th>
                </tr>
            </thead>
        </table>
    </div>
    <div id="dlg" class="easyui-dialog" style="width: 620px; height: 250px; top: 300px; left: 400px; padding: 2px"
        data-options="closed:true,buttons:'#dlg-buttons',modal:true">
        <form id="location" method="post">
            <table>
                <tr>
                    <td>所属大区:
                    </td>
                    <td>
                         <input id="hiddenAREAPORTID" name="hiddenAREAPORTID" type="hidden" />
                        <input id="AreaID1" class="easyui-combobox" name="AreaID1" style="width: 155px;" data-options="required:true,valueField:'fieldvalue',textField:'lookup',url:'@Url.Action("AreaList", "AreaPort", new { IsSetAll = "0" })',editable:false">
                    </td>
                    <td>发货口:
                    </td>
                    <td colspan="2">
                        <input id="PortID1" class="easyui-combobox" name="PortID1" style="width: 155px;" data-options="required:true,valueField:'fieldvalue',textField:'lookup',url:'@Url.Action("SendPortList", "AreaPort", new { IsSetAll = "0" })',editable:false">
                    </td>
                </tr>
                <tr>
                    <td>备注:
                    </td>
                    <td colspan="4">
                        <input id="txtRemark" name="txtRemark" maxlength="255" style="width: 520px" />
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <a id="btnSave" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-save'" onclick="saveData(false)">保存</a>
                    </td>
                </tr>
            </table>
        </form>
    </div>
    @Html.Partial("~/Views/Shared/_PartialToolbar.cshtml", new Toolbar
{
    GridName = "dg",
    GridType = "datagrid",
    ToolbarName = "toolbar",
    FunctionModule = new Dictionary<string, List<FunctionModule>>()
    {
        {"Function",new List<FunctionModule>()
            {
              new FunctionModule(){Name = "Add",IsEnable =true },
              new FunctionModule(){Name = "Edit",IsEnable =true },
              new FunctionModule(){Name = "Remove",IsEnable =true },
              new FunctionModule(){Name = "Reload",IsEnable =false },
              new FunctionModule(){Name = "Collapse",IsEnable =false },
              new FunctionModule(){Name = "Exporter",IsEnable =false },
              
            }
        }
    }
})

</body>


